import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

/** 状态定义 */
export const state = {
  themeObj: {
    top_image:process.env.VUE_BLOG_URL+'/static/img/headbg02.jpg',
    head_portrait:process.env.VUE_BLOG_URL+'/static/img/avatar.jpg',
    center_smailimg:process.env.VUE_BLOG_URL+'/static/img/avatarCard.jpg'
  },//主题
  errorImg: '@/../static/img/tou.jpg',
  articleId: 1,//当前阅读文章
  categoryId: -1,//当前阅读分类

  token:'',//当前用户token
  username:'',
  password:'',
  nickname:'',
  userId:-1
}

export const getters={
  articleId: state => state.articleId,
  categoryId: state => state.categoryId,
  token: state => state.token,
  username:state => state.username,
  nickname:state => state.nickname,
  password:state => state.password,
  userId:state =>state.userId,
  errorImg: state => state.errorImg
}

export const mutations = {
    setArticleId:(state,articleId) =>{
        state.articleId = articleId
    },
    logout:(state) =>{
      state.articleId = -1
      state.categoryId = -1
      state.token = ''
      state.username =''
      state.nickname = ''
      state.password =''
      state.userId= -1
    }

}

export default new Vuex.Store({
    state,
    getters,
    mutations
})
